#include <iostream>
#include <sstream>
#include <string>

std::string decimalToHex(int decimal) {
    std::stringstream ss;
    ss << std::hex << decimal;  // 设置为十六进制输出模式
    return ss.str();
}

int hexToDecimal(const std::string& hex) {
    int decimal;
    std::stringstream ss(hex);
    ss >> std::hex >> decimal;  // 读取十六进制数
    return decimal;
}

int main() {
    // Example usage of decimal to hexadecimal
    int decimal = 255;
    std::string hex = decimalToHex(decimal);
    std::cout << "Decimal: " << decimal << " to Hexadecimal: " << hex << std::endl;

    // Example usage of hexadecimal to decimal
    std::string hexInput = "ff";
    int decimalResult = hexToDecimal(hexInput);
    std::cout << "Hexadecimal: " << hexInput << " to Decimal: " << decimalResult << std::endl;

    return 0;
}